﻿using System.Configuration;
using System;
using System.IO;
using System.Collections.Generic;
using System.Text;
using System.Data;


using RAD.LightOne;

namespace RAD.LightOne.Tester
{
    [DBTable("Aluno")]
    public class Aluno : MyObject<Aluno>, IFull<Aluno>
    {
        [DBField("name")]
        private string name;

        [DBField("parent")]
        private Aluno parent;

        [DBField("age")]
        private int age;

        public Aluno Parent
        {
            get { return parent; }
            set { parent = value; }
        }

        public string Name
        {
            get { return name; }
            set { name = value; }
        }

        public int Age
        {
            get { return age; }
            set { age = value; }
        }

        public Nota[] Notas
        {
            get
            {
                return Nota.FindBySql("select id, class_name from Nota where aluno={0}", this);
            }
        }

        internal Aluno(Guid id) : base(id) { }

        public Aluno() : base() { }

        protected override void OnSaving(IDbTransaction trx)
        {
            base.OnSaving(trx);
        }

        #region ISaveAcessible Members

        public void Save()
        {
            base.Save();
        }

        public void Save(IDbTransaction trx)
        {
            base.Save(trx);
        }

        #endregion

        #region ILoadAcessible Members

        public void Load()
        {
            base.Load();
        }

        public void Load(IDbTransaction trx)
        {
            base.Load(trx);
        }

        #endregion

        #region IDeleteAcessible Members

        public void Delete()
        {
            base.Delete();
        }

        public void Delete(IDbTransaction trx)
        {
            base.Delete(trx);
        }

        #endregion
    }

    [DBTable("AlunoVip")]
    public class AlunoVip : Aluno
    {
        [DBField("qi")]
        private int qi;

        public int Qi
        {
            get { return qi; }
            set { qi = value; }
        }

        [DBField("credit")]
        private double credit;

        public double Credit
        {
            get { return credit; }
            set { credit = value; }
        }

        [DBField("obs")]
        private string obs;

        public string Obs
        {
            get { return obs; }
            set { obs = value; }
        }

        internal AlunoVip(Guid id) : base(id) { }

        public AlunoVip() : base() { }
    }

    [DBTable("Nota")]
    public class Nota : MyObject<Nota>, IFull<Nota>
    {
        [DBField("aluno")]
        private Aluno aluno;

        public Aluno Aluno
        {
          get { return aluno; }
        }

        [DBField("materia")]
        private string materia;

        public string Materia
        {
            get { return materia; }
            set { materia = value; }
        }

        [DBField("valor")]
        private decimal valor;

        public decimal Valor
        {
            get { return valor; }
            set { valor = value; }
        }

        internal Nota(Guid id) : base(id) { }

        public Nota(Aluno aluno) : base()
        {
            this.aluno = aluno;
        }

        public static Nota[] FindaByAluno(Aluno aluno)
        {
            return  Nota.FindBySql("select id, class_name from nota where aluno={0}", aluno);
        }

        #region ISaveAcessible Members

        public void Save()
        {
            base.Save();
        }

        public void Save(IDbTransaction trx)
        {
            base.Save(trx);
        }

        #endregion

        #region ILoadAcessible Members

        public void Load()
        {
            base.Load();
        }

        public void Load(IDbTransaction trx)
        {
            base.Load(trx);
        }

        #endregion

        #region IDeleteAcessible Members

        public void Delete()
        {
            base.Delete();
        }

        public void Delete(IDbTransaction trx)
        {
            base.Delete(trx);
        }

        #endregion
    }

}
